#!/bin/bash

ROOT=`pwd`

# download aarch64
if [ ! -d $ROOT/aarch64 ]; then
    wget https://repo.huaweicloud.com/harmonyos/compiler/aarch64/aarch64.tar.gz -O $ROOT/aarch64.tar.gz
    tar -xzf $ROOT/aarch64.tar.gz -C $ROOT/
    rm -rf $ROOT/aarch64.tar.gz
else
    echo "$ROOT/aarch64 -- already existed !!"
fi

# download llvm(clang/clang++)
if [ ! -d $ROOT/llvm ]; then
    wget https://repo.huaweicloud.com/harmonyos/compiler/clang/10.0.1-62608/linux/llvm.tar.gz -O $ROOT/llvm.tar.gz
    tar -xzf $ROOT/llvm.tar.gz -C $ROOT/
    rm -rf $ROOT/llvm.tar.gz
else
    echo "$ROOT/llvm -- already existed !!"
fi

# copy sysroot from DevEcoStudio sdk folder
if [ ! -d $ROOT/sysroot ]; then
    unzip $ROOT/sysroot-2.1.1.21.zip -d $ROOT/
    if [ ! -d $ROOT/sysroot ]; then
        echo "Please copy [sysroot folder] from DevEcoStudio sdk to here [$ROOT/] ..."
    fi
else
    echo "$ROOT/sysroot -- already existed !!"
fi
